﻿/// <reference path="JSintellisense/jquery-1.3.2-vsdoc2.js" />

function getsendfee(shopid, price, lat, lng) {
   jQuery.ajax(
   {
       type: "post",
       url: "/ajaxHandler.ashx",
       data: "method=getSendFee&shopid=" + shopid + "&lat=" + lat + "&lng=" + lng + "&price=" + price + "&time=" + new Date().getTime() + "",
       success: function (msg) {
           
           parsedata(msg);

           Loader.hide("#btgetfee");


           getDelivergetfee();
       }
   })
}


function getDelivergetfee() {

    jQuery.ajax(
    {
        type: "post",
        url: "/ajaxHandler.ashx",
        data: "method=getDelivergetfee&shopid=" + $("#hftid").val() + "&distance=" + $("#tbcardpay").val() + "&sendtime=" + $("#ddltime").val() + "&time=" + new Date().getTime() + "",
        success: function (msg) {

            var json = eval("(" + msg + ")");

            if (json.Distance == 0) {
                json.Distance = $("#tbshopdiscountmoney").val();
            }

            $("#tbdelivergetfee_base").val(json.Distance);
           

        }
    })
}

function parsedata(msg)
{
    var json = eval("(" + msg + ")");
    $("#tbcardpay").val(json.Distance);
    $("#tbshopdiscountmoney").val(json.sendmoney);

    $("#tbshopdiscountmoney").attr("data-value", json.sendmoney);
}

function startcur()
{
    var tbPrice = $("#tbPrice").val();
    if (tbPrice == "") {
        alert("请输入总金额");;
        return;
    }
    Loader.show("#btgetfee");
    getsendfee($("#hftid").val(), $("#tbPrice").val(), $("#hidLat").val(), $("#hidLng").val())
}

//手动修改配费，要手动修改基数
function checkincome()
{
    var box = $("#tbshopdiscountmoney");
    if (parseFloat(box.val()) != parseFloat(box.attr("data-value"))) {
        $("#base_box").show();

    }
    else {
        $("#base_box").hide();
    }
}